from data_visualization.html_data_visualization import HtmlDataVisualization


class MapMarker(HtmlDataVisualization):
    overlay_type = "marker"
    lng_name = ""
    lat_name = ""
    title_name = ""
    lngs = []
    lats = []
    titles = []
    
    def __init__(self):
        HtmlDataVisualization.__init__(self)
        self.algorithm_name = "地图标注"
        self.html_template_name = "map_marker-template.html"
        
    def setLngLatAndTitleName(self, lng_name, lat_name, title_name):
        self.lng_name = lng_name
        self.lat_name = lat_name
        self.title_name = title_name
        self.lngs = self.data_source[self.lng_name].values.tolist()
        self.lats = self.data_source[self.lat_name].values.tolist()
        self.titles = self.data_source[self.title_name].values.tolist()
    
    def prepareHtmlItems(self):
        HtmlDataVisualization.prepareHtmlItems(self)
        self.html_items["#lngs#"] = self.lngs
        self.html_items["#lats#"] = self.lats
        self.html_items["#titles#"] = self.titles
        if self.overlay_type == "marker":
            self.html_template_name = "map_marker-template.html"
        else:
            self.html_template_name = "map_marker_label-template.html"

